<#include "/ftl/lib/operations.ftl"/>
<div class="easyui-layout" fit="true">
	<div data-options="region:'center',split:true" >
		<div class="easyui-layout" fit="true" border="false">
			<div region="north"  style="padding:5px;border:1px solid #ddd; background-color: #f4f4f4" id="global_${action_id}"  >
			</div> 
			<div data-options="region:'center',split:true,border:false" style="height: 100px;" >
				<div class="easyui-panel" data-options="border:false,fit:true,href:'${request.contextPath}${namespace?default('')}/page/module-list.htm?action_id=${action_id}'" />
			</div>
		</div>
	</div>
</div>  

<script type="text/javascript">
	function add_${action_id}(){
		$('<div>').dialog({
			href : '${request.contextPath}${namespace?default('')}/page/module-form.htm?action_id=${action_id}',
			width:500,   
			height:600,   
			modal : true,
			title : '${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
			buttons : [ {
				text : '${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
				iconCls : 'icon-edit',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#form_${action_id}').form('submit', {
						url : '${request.contextPath}${namespace?default('')}/page/module-add.json',
						onSubmit: function(){
							return $(this).form('validate');
	    				},
						success : function(json) {
							eval("json="+json);
							$.messager.alert(json.title,json.msg,json.level);
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					});
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
	
	function edit_${action_id}(data){
		$('<div>').dialog({
			href : '${request.contextPath}${namespace?default('')}/page/module-edit.htm?action_id=${action_id}&ajax=false&id='+data.id,
			width:500,   
			height:600,   
			modal : true,
			title : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			buttons : [ {
				text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
				iconCls : 'icon-edit',
				handler : function() {
					var d = $(this).closest('.window-body');
					$('#form_${action_id}').form('submit', {
						url : '${request.contextPath}${namespace?default('')}/page/module-update.json',
						onSubmit: function(){
							return $(this).form('validate');
	    				},
						success : function(json) {
							eval("json="+json);
							$.messager.alert(json.title,json.msg,json.level);
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					});
				}
			} ],
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
	
	function delete_${action_id}(data){
		$.messager.confirm('${action.getText('bg.message.warn')}', '${action.getText('bg.datagrid.delete.ask')}', function(b) {
			if (b) {
				$.ajax({
					url : '${request.contextPath}${namespace?default('')}/page/module-delete.json',
					data:{id : data.id},
					dataType : 'JSON',
					success : function(json) {
						$.messager.alert(json.title,json.msg,json.level);
						$("#datagrid_${action_id}").datagrid('reload');
					}
				});
			}
		});
	}
	
	function moduleLinkType_${action_id}(data){
		$('<div>').dialog({
			href : '${request.contextPath}${namespace?default('')}/page/moduleLinkType-index.htm?moduleId='+data.id,
			width:700,
			height:700,
			modal : true,
			title : '${action.getProperty('net.esj.background.message','bg.datagrid.add')}',
			onClose : function() {
				$(this).dialog('destroy');
			}
		});
	}
</script>
<@operations contextUri='page/module' />